package com.ideaaedi.zoo.example.springboot.bpmn.flowable.controller.demo6.enums;

import com.ideaaedi.zoo.commonbase.enums.EnumDescriptor;
import lombok.Getter;

import java.util.UUID;

/**
 * 工作流相关业务类型
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 1.0.0
 */
@Getter
public enum BpmnBizSceneEnum implements EnumDescriptor {

    XHJQ("XHJQ_", "XHJQ", "向后加签");

    /**
     * id前缀
     */
    private final String idPrefix;

    /**
     * 业务场景scope
     */
    private final String scopeType;

    /**
     * 枚举描述
     */
    private final String desc;

    BpmnBizSceneEnum(String idPrefix, String scopeType, String desc) {
        this.idPrefix = idPrefix;
        this.scopeType = scopeType;
        this.desc = desc;
    }

    @Override
    public String obtainDescription() {
        return this.desc;
    }

    /**
     * 根据id判断是否是当前业务场景
     * @param id 元素id
     *
     * @return 是否是当前业务场景
     */
    public boolean ifCurrSceneById(String id) {
        return id != null && id.startsWith(this.idPrefix);
    }

    /**
     * 根据scopeType判断是否是当前业务场景
     * @param scopeType 域类型
     *
     * @return 是否是当前业务场景
     */
    public boolean ifCurrSceneByScope(String scopeType) {
        return scopeType != null && scopeType.equals(this.scopeType);
    }

    /**
     * 随机id
     *
     * @return 随机id
     */
    public String generateId() {
        return BpmnBizSceneEnum.XHJQ.getIdPrefix() + UUID.randomUUID().toString().replaceAll("-", "");
    }
}
